package be.kuleuven.cs.mop.domain.model.impl;


import static org.junit.Assert.*;

import org.junit.*;

import be.kuleuven.cs.mop.domain.exceptions.TaskManagerException;



public class IntervalTest {
	
	@Test(expected=Exception.class)
	public void testConstructorInvalid0() throws TaskManagerException {
		new Interval(1, 0);
	}
	
	@Test
	public void testConstructorValid() throws TaskManagerException {
		final Interval interval = new Interval(0, 1);
		assertEquals(interval.getLowerLimit(),	0);
		assertEquals(interval.getUpperLimit(),	1);
		
		new Interval(3, false);
		new Interval(5, true);
	}
	
	@Test
	public void testContains() throws TaskManagerException {
		final Interval interval = new Interval(1, 3);
		
		for (int i = 1; i <= 3; i++)
			assertTrue(interval.contains(i));
		assertFalse(interval.contains(0));
		assertFalse(interval.contains(4));
	}
	
	@Test
	public void testSatisfiesLowerLimit() throws TaskManagerException {
		final Interval interval = new Interval(1, 1);
		
		assertFalse(interval.satisfiesLowerLimit(0));
		for (int i = 1; i < 100; i++)
			assertTrue(interval.satisfiesLowerLimit(i));
	}
	
	@Test
	public void testSatisfiesUpperLimit() throws TaskManagerException {
		final Interval interval = new Interval(100, 100);
		
		assertFalse(interval.satisfiesUpperLimit(101));
		for (int i = 100; i >= 0; i--)
			assertTrue(interval.satisfiesUpperLimit(i));
	}
	
}